from machine import Pin, PWM
from time import sleep

led = PWM(Pin(12, Pin.OUT), freq=1000)

while True:
    for brightness in range(65535, 0, -400):
        ratio = brightness / 65535
        led.duty_u16((int)(65535 * ratio * ratio))
        sleep(0.01)

    sleep(0.8)

    for brightness in range(0, 65535, 400):
        ratio = brightness / 65535
        led.duty_u16((int)(65535 * ratio * ratio))
        sleep(0.01)

    sleep(0.8)
